<%#
#  Copyright 2009 Swansea University.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#  under the License.
%>

<% title "Set status" %>

<% if @current_setting %>
  <fieldset><legend>Current setting</legend>
    <h3>Code</h3>
    <p> <%= @current_setting.code %></p>
    <h3>Message</h3><%= textilize(@current_setting.message) %>
    <h3>Default permissions</h3><p><code><%= @current_setting.default_permissions %></code> (<%= @current_setting.default_permissions.to_octal %>)
  </fieldset>
<% else %>
  <p>Currrent status undefined.</p>
<% end %>
<% form_for ([:admin, @status]) do |f| %>
  <%= f.error_messages %>
  <fieldset><legend>Available settings</legend>
    <table>
      <thead>
        <tr>
          <th>Code</th><th>Message</th><th>Default permissions</th><th>Select</th>
        </tr>
      </thead>
      <% @settings.each do |setting| %>
        <tbody>
          <tr class="<%=  cycle('odd', 'even') %>">
            <td>
              <%=  setting.code %>
            </td>
            <td>
              <%= setting.message %>
            </td>
            <td>
              <%= setting.default_permissions.to_s %>
            </td>
            <td><%= f.radio_button :status_setting, setting.id %></td>
          </tr>
        </tbody>
      <%  end %>
    </table>
    <p>
    <p><%= f.submit 'Update' %> <%= link_to 'Cancel', admin_status_settings_path %></p>
  </fieldset>
<% end %>
